<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	</body>
	<script type="text/javascript">
		/* 
			获取当前 localstorage 能够使用的最大大小 
		 */
		/* 抄了一遍 */
		
		
    let testStr = "1234567890";// 增量
    let str = "";//10Bit 10kb === 10240Bit
    for (let i = 0; i < 1024; i++) {
        str = str + testStr;
    }
    // 设置定时器 每隔0.1毫秒的时候 往 　localStorage里面存数据
    let sum = "";// 最终数据的大小
    let timeId = ""
    // 5*1024/10
    let i = 0;
    while (i<513) {
        i++;
        try {
            sum += str;
            console.log((sum.length / 1024 / 1024).toFixed(2), "M");
            // 清除之前的内容 否则叠加
            localStorage.removeItem("sum");
            localStorage.setItem("sum", sum);
        } catch (e) {
            console.log("最终是:",(sum.length / 1024 / 1024).toFixed(2), "M");
        }
    }
    // console.log(str);
	</script>
</html>
